package com.haiya.identityaccess.infrastructure.persistence.mybatis.translation;

import com.haiya.identityaccess.domain.identity.model.Tenant;
import com.haiya.identityaccess.domain.identity.model.TenantId;
import com.haiya.identityaccess.infrastructure.persistence.mybatis.datamodel.DataTenant;

/**
 * @author qiaoguoqiang
 */
public class TenantTranslate {

    public static Tenant toDomainEntity(DataTenant dataEntity) {
        return new Tenant(
                new TenantId(dataEntity.getTenantIdId()),
                dataEntity.getName(),
                dataEntity.getDescription(),
                dataEntity.getActive() == 1);
    }

    public static DataTenant toDataEntity(Tenant domainEntity) {
        return new DataTenant(
                domainEntity.tenantId().id(),
                domainEntity.name(),
                domainEntity.description(),
                domainEntity.isActive() ? 1 : 0
        );
    }
}
